package com.woniuxy.Controller;

import com.woniuxy.entity.RbacMenu;
import com.woniuxy.service.RbacMenuService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (RbacMenu)表控制层
 *
 * @author makejava
 * @since 2021-04-28 22:16:12
 */
@RestController
@RequestMapping("rbacMenu")
public class RbacMenuController {
    /**
     * 服务对象
     */
    @Resource
    private RbacMenuService rbacMenuService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public RbacMenu selectOne(int id) {
        return this.rbacMenuService.queryById(id);
    }

    /**
     * Description : 返回所有菜单的层级结构, 用来动态编辑菜单  <br/>
     * ChangeLog : 1. 创建 (2021/4/29 10:14 [mayuhang]);
     *
     * @return java.util.List<com.woniuxy.entity.RbacMenu>
     **/
    @RequestMapping("findAllMenu")
    @RequiresAuthentication
    public List<RbacMenu>  findAllMenu(){
        return this.rbacMenuService.findAllMenu();
    }
    /**
     * Description : 返回所有菜单的层级结构, 用来动态编辑菜单  <br/>
     * ChangeLog : 1. 创建 (2021/4/29 10:14 [mayuhang]);
     * @param id 角色id
     * @return java.util.List<com.woniuxy.entity.RbacMenu>
     **/
    @RequestMapping("findLeftMenu/{id}")
    public List<RbacMenu>  findLeftMenu(@PathVariable int id){
        return this.rbacMenuService.findLeftMenu(id);
    }
}
